package ingsw2.ii.dp.a;

public class MyBackwardIterator<T> implements MyIterator<T> {

	private int ptr;
	private MyList<T> list;
	
	public MyBackwardIterator(MyList<T> list){
		this.ptr = list.last();
		this.list = list;
	}
	
	@Override
	public void rewind() {
		this.ptr = list.last();
	}

	@Override
	public T nextElement() {
		return list.getElement(this.ptr--);
	}

	@Override
	public boolean hasMoreElements() {
		if (this.ptr >= 0)
			return true;
		else
			return false;
	}
}
